package com.ijustyce.denoise;

import android.os.Bundle;
import android.view.MenuItem;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;
import androidx.navigation.Navigation;

import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.ijustyce.denoise.fragment.DetailFragment;
import com.ijustyce.denoise.fragment.IndexFragment;


public class Menu extends FragmentActivity {

    private BottomNavigationView bottomNavigationView;
    private FloatingActionButton btn;

    public Button tv_findWork;
    private TextView tv_findTalents;
    private Fragment contentFragment;
    private FragmentManager fragmentManager;

    protected void onCreate(Bundle savedInstanceState) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);

        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_menu2);
        bottomNavigationView=(BottomNavigationView)findViewById(R.id.bottomNavigationView);
        bottomNavigationView.getMenu().getItem(0).setChecked(true);

        fragmentManager = getSupportFragmentManager();
        //设置导航栏菜单项Item选中监听
        bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
            @Override
            public boolean onNavigationItemSelected(@NonNull MenuItem item) {
                FragmentTransaction transaction = fragmentManager.beginTransaction();
                switch (item.getItemId()) {
                    case R.id.bottom_navigation1:
                        contentFragment = new IndexFragment();
                        transaction.replace(R.id.fragment_container, contentFragment);
                        break;
                    case R.id.bottom_navigation2:
                        contentFragment = new DetailFragment();
                        transaction.replace(R.id.fragment_container, contentFragment);
                        break;
                    case R.id.bottom_navigation3:
                        contentFragment = new IndexFragment();
                        transaction.replace(R.id.fragment_container, contentFragment);
                        break;
                    case R.id.bottom_navigation4:
                        contentFragment = new IndexFragment();
                        transaction.replace(R.id.fragment_container, contentFragment);
                        break;
                }
                transaction.commit();
                return true;
            }
        });
    }

}
